<?php class Users { 

    /***
     * DB Fields: id
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $id;

    /***
     * DB Fields: nick
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $nick;

    /***
     * DB Fields: pass
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $pass;

    /***
     * DB Fields: email
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $email;

    /***
     * DB Fields: created
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $created;

    /***
     * DB Fields: active
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $active;

    /***
     * DB Fields: lastLogin
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $lastLogin;

    /***
     * DB Fields: homePlanet
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $homePlanet;

    /***
     * DB Fields: maxBuild
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $maxBuild;

    /***
     * DB Fields: maxResearch
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $maxResearch;

    /***
     * DB Fields: maxPlanets
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $maxPlanets;

    /***
     * DB Fields: maxFleet
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $maxFleet;

    /***
     * DB Fields: rol
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $rol;

//--------------- GET METHODS ----------------------------- //
    /***
     * Get value for field: id
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result id
     **/
    function get_id( ) {
        // returns the value of id
        return $this->id;
    }


    /***
     * Get value for field: nick
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result nick
     **/
    function get_nick( ) {
        // returns the value of nick
        return $this->nick;
    }


    /***
     * Get value for field: pass
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result pass
     **/
    function get_pass( ) {
        // returns the value of pass
        return $this->pass;
    }


    /***
     * Get value for field: email
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result email
     **/
    function get_email( ) {
        // returns the value of email
        return $this->email;
    }


    /***
     * Get value for field: created
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result created
     **/
    function get_created( ) {
        // returns the value of created
        return $this->created;
    }


    /***
     * Get value for field: active
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result active
     **/
    function get_active( ) {
        // returns the value of active
        return $this->active;
    }


    /***
     * Get value for field: lastLogin
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result lastLogin
     **/
    function get_lastLogin( ) {
        // returns the value of lastLogin
        return $this->lastLogin;
    }


    /***
     * Get value for field: homePlanet
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result homePlanet
     **/
    function get_homePlanet( ) {
        // returns the value of homePlanet
        return $this->homePlanet;
    }


    /***
     * Get value for field: maxBuild
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result maxBuild
     **/
    function get_maxBuild( ) {
        // returns the value of maxBuild
        return $this->maxBuild;
    }


    /***
     * Get value for field: maxResearch
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result maxResearch
     **/
    function get_maxResearch( ) {
        // returns the value of maxResearch
        return $this->maxResearch;
    }


    /***
     * Get value for field: maxPlanets
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result maxPlanets
     **/
    function get_maxPlanets( ) {
        // returns the value of maxPlanets
        return $this->maxPlanets;
    }


    /***
     * Get value for field: maxFleet
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result maxFleet
     **/
    function get_maxFleet( ) {
        // returns the value of maxFleet
        return $this->maxFleet;
    }


    /***
     * Get value for field: rol
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result rol
     **/
    function get_rol( ) {
        // returns the value of rol
        return $this->rol;
    }


//--------------- SET METHODS ----------------------------- //
    /***
     * Set value for field: id
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @result void
     **/
    function set_id( $id ) {
        // sets the value of id
        $this->id = $id;
    }

    /***
     * Set value for field: nick
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param nick
     * @result void
     **/
    function set_nick( $nick ) {
        // sets the value of nick
        $this->nick = $nick;
    }

    /***
     * Set value for field: pass
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param pass
     * @result void
     **/
    function set_pass( $pass ) {
        // sets the value of pass
        $this->pass = $pass;
    }

    /***
     * Set value for field: email
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param email
     * @result void
     **/
    function set_email( $email ) {
        // sets the value of email
        $this->email = $email;
    }

    /***
     * Set value for field: created
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param created
     * @result void
     **/
    function set_created( $created ) {
        // sets the value of created
        $this->created = $created;
    }

    /***
     * Set value for field: active
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param active
     * @result void
     **/
    function set_active( $active ) {
        // sets the value of active
        $this->active = $active;
    }

    /***
     * Set value for field: lastLogin
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param lastLogin
     * @result void
     **/
    function set_lastLogin( $lastLogin ) {
        // sets the value of lastLogin
        $this->lastLogin = $lastLogin;
    }

    /***
     * Set value for field: homePlanet
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param homePlanet
     * @result void
     **/
    function set_homePlanet( $homePlanet ) {
        // sets the value of homePlanet
        $this->homePlanet = $homePlanet;
    }

    /***
     * Set value for field: maxBuild
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param maxBuild
     * @result void
     **/
    function set_maxBuild( $maxBuild ) {
        // sets the value of maxBuild
        $this->maxBuild = $maxBuild;
    }

    /***
     * Set value for field: maxResearch
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param maxResearch
     * @result void
     **/
    function set_maxResearch( $maxResearch ) {
        // sets the value of maxResearch
        $this->maxResearch = $maxResearch;
    }

    /***
     * Set value for field: maxPlanets
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param maxPlanets
     * @result void
     **/
    function set_maxPlanets( $maxPlanets ) {
        // sets the value of maxPlanets
        $this->maxPlanets = $maxPlanets;
    }

    /***
     * Set value for field: maxFleet
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param maxFleet
     * @result void
     **/
    function set_maxFleet( $maxFleet ) {
        // sets the value of maxFleet
        $this->maxFleet = $maxFleet;
    }

    /***
     * Set value for field: rol
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param rol
     * @result void
     **/
    function set_rol( $rol ) {
        // sets the value of rol
        $this->rol = $rol;
    }

//--------------- CRUD METHODS ----------------------------- //
    /***
     * Create a new Record: users
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @param nick
     * @param pass
     * @param email
     * @param created
     * @param active
     * @param lastLogin
     * @param homePlanet
     * @param maxBuild
     * @param maxResearch
     * @param maxPlanets
     * @param maxFleet
     * @param rol
     * @result void
     **/
    function createnew_users( $id, $nick, $pass, $email, $created, $active, $lastLogin, $homePlanet, $maxBuild, $maxResearch, $maxPlanets, $maxFleet, $rol ) {

        // items to be inserted in the database 
        $_obj = array($id,
                      $nick,
                      $pass,
                      $email,
                      $created,
                      $active,
                      $lastLogin,
                      $homePlanet,
                      $maxBuild,
                      $maxResearch,
                      $maxPlanets,
                      $maxFleet,
                      $rol); 

        // database object connection
        $dbConn = $GLOBALS['dbConn'];

        // perform insert in the database
        $dbConn->insert("users", $_obj);
    }

    /***
     * Retrived an existing record: users
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @result new Users
     **/
    function get_users( $id ) {

        // retrive the data
        $dbConn = $GLOBALS['dbConn'];

        // retrieved value in the database
        $_resultSet = $dbConn->doQuery("SELECT * FROM users WHERE id = '$id'");

        $__usersObj = new users();
        // return the retrived from the database

        // create a new object
        $__obj = new Users();
        $__obj->set_id($_resultSet[0]['id']);
        $__obj->set_nick($_resultSet[0]['nick']);
        $__obj->set_pass($_resultSet[0]['pass']);
        $__obj->set_email($_resultSet[0]['email']);
        $__obj->set_created($_resultSet[0]['created']);
        $__obj->set_active($_resultSet[0]['active']);
        $__obj->set_lastLogin($_resultSet[0]['lastLogin']);
        $__obj->set_homePlanet($_resultSet[0]['homePlanet']);
        $__obj->set_maxBuild($_resultSet[0]['maxBuild']);
        $__obj->set_maxResearch($_resultSet[0]['maxResearch']);
        $__obj->set_maxPlanets($_resultSet[0]['maxPlanets']);
        $__obj->set_maxFleet($_resultSet[0]['maxFleet']);
        $__obj->set_rol($_resultSet[0]['rol']);


        return $__obj;
    }

    /***
     * Update an existing record: users
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @param itemsToBeUpdated = array()
     * @result void
     **/
    function update_users( $id, $itemsToBeUpdated = array() ) {

         // get database connection
         $dbConn = $GLOBALS['dbConn'];

         // performs update in the database
         foreach($itemsToBeUpdated as $_fName => $_fVal) { 
               $dbConn->addValuePair($_fName, $_fVal);
         }

         // perform update operation
         $dbConn->update("users", "id = '$id'");
    }

    /***
     * Delete an existing record: users
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @result void
     **/
    function delete_users( $id ) {

         // get database connection
         $dbConn = $GLOBALS['dbConn'];

         // performs deletion of data
         $dbConn->delete("users", "id = '$id'");
    }

    /***
     * Retrived list of objects base on a given parameters: users
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param conditionalStatement = ''
     * @result collection of objects: Users
     **/
    function list_users( $conditionalStatement = '' ) {

         $dbConn = $GLOBALS['dbConn'];
         // check if there is a given parameter list
         if(!empty($conditionalStatement)) { 
              $sqlStatement = "SELECT * FROM users WHERE $conditionalStatement"; 
         } else { 
              $sqlStatement = "SELECT * FROM users";
         }

         // retrieve the values base on the query result
         $__resObj = $dbConn->doQuery($sqlStatement);

         $__collectionOfObjects = array();
         foreach($__resObj as $__rs) { 
            $__newObj = new Users();

            $__newObj->set_id($__rs['id']);
            $__newObj->set_nick($__rs['nick']);
            $__newObj->set_pass($__rs['pass']);
            $__newObj->set_email($__rs['email']);
            $__newObj->set_created($__rs['created']);
            $__newObj->set_active($__rs['active']);
            $__newObj->set_lastLogin($__rs['lastLogin']);
            $__newObj->set_homePlanet($__rs['homePlanet']);
            $__newObj->set_maxBuild($__rs['maxBuild']);
            $__newObj->set_maxResearch($__rs['maxResearch']);
            $__newObj->set_maxPlanets($__rs['maxPlanets']);
            $__newObj->set_maxFleet($__rs['maxFleet']);
            $__newObj->set_rol($__rs['rol']);

            // add object to collection 
            array_push($__collectionOfObjects, $__newObj);
         }

         // return collection of objects
         return $__collectionOfObjects;
    }

} ?>